package com.wisely.highlight_spring4.ch2.event;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @ClassName DemoListener
 * @Package com.wisely.highlight_spring.ch2.event
 * @Description TODO
 * @Author zjb
 * @Date 2018/7/20 12:21
 * @Version 1.0
 **/
@Component
//实现ApplicationListener接口,并指定监听的事件类型
public class DemoListener implements ApplicationListener<DemoEvent> {
    //使用onApplicationEvent方法对消息进行接受处理
    @Override
    public void onApplicationEvent(DemoEvent event) {
        String msg = event.getMsg();
        System.out.println("我(bean-dempListener)接收到了bean-demoPublisher发布的消息: " + msg);
    }
}
